package com.framework.seedkit.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.framework.seedkit.R;
import com.framework.seedkit.base.BaseFragment;
import com.framework.seedkit.customwidget.PagerSlidingTabStrip;


/**
 * author：yisong on 2016/6/12 14:53
 */
public class TestFrag1 extends BaseFragment {
    private String TAG = "TestFrag1";
    private PagerSlidingTabStrip tabstrip;
    private ViewPager viewPager;
    private GrabOrderAdapter adapter;
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.frag_frag;
    }

    @Override
    public void initView() {
        tabstrip = (PagerSlidingTabStrip) view.findViewById(R.id.forder_grab_tabstrip);
        tabstrip.setTextSize(mContext.getResources().getDimensionPixelSize(R.dimen.tabstrip_size));
        tabstrip.setTextColor(mContext.getResources().getColor(R.color.gray_color));
        tabstrip.setTabSelectTextResource(R.color.red_color);
        tabstrip.setTabPaddingLeftRight(mContext.getResources().getDimensionPixelSize(R.dimen.tabstrip_padding1));
        viewPager = (ViewPager) view.findViewById(R.id.forder_grab_viewpager);
        viewPager.setOffscreenPageLimit(4);

        adapter = new GrabOrderAdapter(getChildFragmentManager());
        viewPager.setAdapter(adapter);
        tabstrip.setViewPager(viewPager);
    }

    @Override
    public void initData() {
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Log.d(TAG, "onDestroyView");
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    public TestFrag1() {

    }

    private class GrabOrderAdapter extends FragmentPagerAdapter {

        private final String[] TITLES = {"全部客户", "待匹配", "匹配成功", "佣金到账"};

        public GrabOrderAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return TITLES[position];
        }

        @Override
        public int getCount() {
            return TITLES.length;
        }

        @Override
        public Fragment getItem(int position) {
            Fragment frgment = null;
            switch (position) {
                case 0:
                case 1:
                case 2:
                case 3:
                    frgment = new MyFragment();
                    break;
                default:
                    break;
            }

            return frgment;
        }
    }
}
